home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.cs.arizona.edu
/
ftp.cs.arizona.edu.tar
/
ftp.cs.arizona.edu
/
icon
/
newsgrp
/
group93c.txt
/
000047_icon-group-sender _Sun Sep 12 19:15:12 1993.msg
< prev
next >
Wrap
Internet Message Format
|
1994-02-02
|
2KB
Received: from owl.CS.Arizona.EDU by cheltenham.cs.arizona.edu; Mon, 13 Sep 1993 07:33:29 MST
Received: by owl.cs.arizona.edu; Mon, 13 Sep 1993 07:33:28 MST
Date: 12 Sep 93 19:15:12 GMT
From: ucivax!gateway@ucbvax.Berkeley.EDU (Owen O'Malley)
Subject: Re: Help on a simple problem.
Message-Id: <3441.747861298@porte-de-st-ouen.ics.uci.edu>
References: <26qre8INNq0g@dns1.NMSU.Edu>
Sender: icon-group-request@cs.arizona.edu
To: icon-group@cs.arizona.edu
Status: R
Errors-To: icon-group-errors@cs.arizona.edu
>I have the following program that just computers a number to a certain
>power....I also have it written to write the output to a file...my
>problem is this...with very large numbers, i get a huge result
>which ends up being written as 1 line. Is there a way I could
>split the output up so that it is written to numerous lines, 80 chars
>per line. Ie: If you asked it to do 2 to the 5000th power you would
>get a number that was 15-20 lines long...i need that to be printed
>in a file as 15-20 seperate lines, not just one line.
The way that I would do it is:
# Note: I took the liberty of changing your algorithm so that it
# actually computes x^y
# Line_Break take a character and prints it out, possibly with a line
# break. I choose to make it handle a character, but you could easily
# move the ! inside the procedure and pass in an entire string.
procedure Line_Break(ch)
static posn;
initial {posn:=1}
if posn > 72 then {
write();
posn := 1;
}
writes(ch);
posn +:= 1;
end
procedure main()
write("Please enter a number. ")
n := read()
write("Please enter another number. ")
num:=read()
count:=1;
every 1 to num do {
count *:= n
}
write()
if num = 3 | num % 10 - 3 = 0 & num != 13 then
write(n, " to the ", num,"rd power is: ")
else if num = 2 | num % 10 - 2 = 0 & num != 12 then
write(n, " to the ", num,"nd power is: ")
else
write(n, " to the ", num, "th power is: ")
every Line_Break(!count);
write()
end